import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'

import { GroupListComponent } from './list/list.component'
import { GroupNewComponent } from './new/new.component'
import { NewRouterGuardClass } from '@shared/classes/NewRouterGuardClass'
import { GroupDetailComponent } from './detail/detail.component'
import { GroupDetailTabMerchantsComponent } from './detail/tab-merchants/tab-merchants.component'
import { GroupDetailTabSysteminfosComponent } from './detail/tab-systeminfos/tab-systeminfos.component'
import { GroupDetailTabUserlistComponent } from './detail/tab-userlist/tab-userlist.component'
import { ListRouterGuardClass } from '@shared/classes/ListRouterGuardClass'
import { ListReuseGuardClass } from '@shared/classes/ListReuseGuardClass';

const routes: Routes = [
  { path: '', redirectTo: 'list', pathMatch: 'full' },
  {
    path: 'list',
    component: GroupListComponent,
    canActivate: [ListRouterGuardClass, ListReuseGuardClass],
    pathMatch: 'full',
    data: {
      title: '集团列表',
      titleI18n: 'MENU.BIZ.AGENTS',
      reuse: true,
    },
  },
  {
    path: 'new',
    component: GroupNewComponent,
    canDeactivate: [NewRouterGuardClass],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.CREATE',
      titleI18n: 'BIZ.AGENT.TITLE.CREATE',
    },
  },
  {
    path: ':id',
    component: GroupDetailComponent,
    children: [
      { path: '', redirectTo: 'merchants', pathMatch: 'full' },
      {
        path: 'merchants',
        component: GroupDetailTabMerchantsComponent,
        data: {
          titleI18n: 'BIZ.AGENT.TITLE.DETAIL',
        },
      },
      {
        path: 'systeminfos',
        component: GroupDetailTabSysteminfosComponent,
        data: {
          titleI18n: 'BIZ.AGENT.TITLE.DETAIL',
        },
      },
      {
        path: 'userlist',
        component: GroupDetailTabUserlistComponent,
        data: {
          titleI18n: 'BIZ.AGENT.TITLE.DETAIL',
        },
      },
    ],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.DETAIL',
      titleI18n: 'BIZ.AGENT.TITLE.DETAIL',
    },
  },
]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class GroupRoutingModule {}
